Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add evm provider and logger #10

Closed
wants to merge 4 commits into from
Closed

Conversation

0xkenj1
Copy link
Collaborator

@0xkenj1 0xkenj1 commented Oct 15, 2024

Description

  • Abstraction for interactions with EVM chains in chain-providers
  • Generic Logger in shared
  • Fixed tests naming
  • Fixed tsconfig to include test in check-types script
  • Fixed typing issues on pricing tests

Checklist before requesting a review

  • I have conducted a self-review of my code.
  • I have conducted a QA.
  • If it is a core feature, I have included comprehensive tests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing the export of the Logger class

jahabeebs
jahabeebs previously approved these changes Oct 15, 2024
Copy link
Collaborator

@jahabeebs jahabeebs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some small suggestions if you want to address 👍🏻

}

this.client = createPublicClient({
chain,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: do we need any validation of the chain? It's completely optional here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should add a validation to ensure that multicall works, thats the only thing that conserns me, just to avoid throwing in the case multicall address doesn't exist. Or maybe providing another way as fallback mechanism like a Promise.all in case there is no multicall contract (we already talk about the last one with nigiri).

Lets move forward as it is and keep track of this in linear, to tackle the issue in the future.

});

describe("getGasPrice", () => {
it("should return the current gas price", async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is picky but I think we are supposed to avoid writing "should" for every it() statement and instead just say "returns.."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, will take this to fix during future pr :)

0xnigir1
0xnigir1 previously approved these changes Oct 16, 2024
Copy link
Collaborator

@0xyaco 0xyaco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice typing. Left two small comments.

* @returns {Promise<bigint>} A Promise that resolves to the latest block number.
*/
async getBlockNumber(): Promise<bigint> {
return this.client.getBlockNumber();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty convoluted but just wanted to tell that getBlockNumber by default caches the result by 4 seconds (ie default client's polling interval). [1]

Not sure if this is relevant but might be.

[1] https://viem.sh/docs/actions/public/getBlockNumber.html#cachetime-optional

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this is that relevant, we typically have all the events linked to the blocknumbers where they were emitted

cc @0xnigir1 ??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it's unlinkely we have an issue with this, its not that we call this method for every event. anyway, lets keep an eye an eventually we set it to 0

Comment on lines 89 to 91
async getBlockByNumber(blockNumber: number): Promise<GetBlockReturnType> {
return this.client.getBlock({ blockNumber: BigInt(blockNumber) });
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason to use number over bigint here? With this interface, someone could pass blockNumber = 5.5 as an argument and BigInt(blockNumber) would explode.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch king

@0xkenj1 0xkenj1 dismissed stale reviews from 0xnigir1 and jahabeebs via dd1a922 October 16, 2024 17:07
@0xnigir1 0xnigir1 mentioned this pull request Oct 16, 2024
3 tasks
@0xkenj1
Copy link
Collaborator Author

0xkenj1 commented Oct 16, 2024

There is a bug in the UI and can't be merged

@0xkenj1 0xkenj1 closed this Oct 16, 2024
@0xkenj1 0xkenj1 deleted the feat/providers-and-logger branch October 16, 2024 18:32
@0xkenj1 0xkenj1 restored the feat/providers-and-logger branch October 16, 2024 18:32
@0xkenj1 0xkenj1 deleted the feat/providers-and-logger branch October 16, 2024 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants